<?php
require_once "header_before_menu.php";
require_once "db.php";
require_once "util.php";

get_database_connection();

$login = $_REQUEST["login"];
$password = $_REQUEST["password"];

$sql = "SELECT * FROM users WHERE login = '$login' AND password = '$password'";
$query = mysql_query($sql);

if (mysql_num_rows($query) == 0) {
  set_flash("Login nao encontrado.");
  ddd_redirect("index.php");
} else {
  $data = mysql_fetch_assoc($query);

  set_flash("Bem-vindo, " . $data["login"]);
  set_cookie("user_id", $data["id"]);
  set_cookie("user_login", $data["login"]);

  ddd_redirect("index.objects.php");
}

?>

<?php
require_once "footer.php";
?>
